<?php
	class diemcndb
	{
		public function Add($MaHocSinh, $MaMonHoc, $NamHoc, $DTB_CN)
		{
			$sql = "INSERT INTO `tbl_diemcn`(`MaHocSinh`, `MaMonHoc`, `NamHoc`, `DTB_CN`)  
			VALUES ('$MaHocSinh', $MaMonHoc, '$NamHoc', $DTB_CN)";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaHocSinh, $MaMonHoc, $NamHoc)
		{
			$sql = "DELETE FROM `tbl_diemcn`
			WHERE MaHocSinh = '$MaHocSinh' AND MaMonHoc = $MaMonHoc AND NamHoc = '$NamHoc'  "; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaHocSinh, $MaMonHoc, $NamHoc, $DTB_CN)
		{
			$sql = "UPDATE  `tbl_diemcn` 
			 SET DTB_CN = $DTB_CN
			WHERE MaHocSinh = '$MaHocSinh' AND MaMonHoc = $MaMonHoc AND NamHoc = '$NamHoc'  "; 
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
	
	
		public function GetList($MaHocSinh, $MaMonHoc, $NamHoc)
		{
			$sql = " SELECT * FROM  `tbl_diemcn`,`tbl_hocsinh`,`tbl_monhoc`, `tbl_namhoc`, `tbl_lop`,`tbl_hocsinh_lop`,`tbl_phanlop` WHERE  tbl_diemcn.MaHocSinh = tbl_hocsinh.MaHocSinh AND tbl_diemcn.MaMonHoc = tbl_monhoc.MaMonHoc AND tbl_diemcn.NamHoc = tbl_namhoc.NamHoc AND tbl_lop.MaLop = tbl_phanlop.MaLop AND tbl_phanlop.MaPhanLop = tbl_hocsinh_lop.MaPhanLop AND tbl_hocsinh.MaHocSinh = tbl_hocsinh_lop.MaHocSinh ";
			if($MaHocSinh!="")
				$sql .= " AND tbl_diemcn.MaHocSinh = '$MaHocSinh' ";
			if($MaMonHoc!="")
				$sql .= " AND tbl_diemcn.MaMonHoc = $MaMonHoc ";
			if($NamHoc!="")
				$sql .= " AND tbl_diemcn.NamHoc = '$NamHoc' ";			
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
		
	}
?>